package BLC

import (
	"crypto/ecdsa"
	"crypto/elliptic"
	"crypto/rand"
	"fmt"
	"log"
)

type Wallet struct {
	//1. 私钥
	PrivateKey ecdsa.PrivateKey

	// 2. 公钥
	PublicKey []byte
}

// 创建钱宝
func NewWallet() *Wallet{
	privateKey , publicKey := newKeyPair()

	fmt.Println(privateKey)
	fmt.Println(publicKey)

	return &Wallet{privateKey,publicKey}
}

// 通过私钥产生私钥
func newKeyPair() (ecdsa.PrivateKey,[]byte){

	curve := elliptic.P256()
	private , err := ecdsa.GenerateKey(curve,rand.Reader)
	if err != nil {
		log.Panic(err)
	}

	pubkey := append(private.PublicKey.X.Bytes(),private.PublicKey.Y.Bytes()...)

	return *private, pubkey

}

